package com.ruoyi.yqhs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yqhs.domain.YqhsJdjc;
import com.ruoyi.yqhs.service.IYqhsJdjcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 监督检查Controller
 * 
 * @author ruoyi
 * @date 2025-08-31
 */
@RestController
@RequestMapping("/yqhs/jdjc")
public class YqhsJdjcController extends BaseController
{
    @Autowired
    private IYqhsJdjcService yqhsJdjcService;

    /**
     * 查询监督检查列表
     */
    @PreAuthorize("@ss.hasPermi('yqhs:jdjc:list')")
    @GetMapping("/list")
    public TableDataInfo list(YqhsJdjc yqhsJdjc)
    {
        startPage();
        List<YqhsJdjc> list = yqhsJdjcService.selectYqhsJdjcList(yqhsJdjc);
        return getDataTable(list);
    }

    /**
     * 导出监督检查列表
     */
    @PreAuthorize("@ss.hasPermi('yqhs:jdjc:export')")
    @Log(title = "监督检查", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqhsJdjc yqhsJdjc)
    {
        List<YqhsJdjc> list = yqhsJdjcService.selectYqhsJdjcList(yqhsJdjc);
        ExcelUtil<YqhsJdjc> util = new ExcelUtil<YqhsJdjc>(YqhsJdjc.class);
        util.exportExcel(response, list, "监督检查数据");
    }

    /**
     * 获取监督检查详细信息
     */
    @PreAuthorize("@ss.hasPermi('yqhs:jdjc:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yqhsJdjcService.selectYqhsJdjcById(id));
    }

    /**
     * 新增监督检查
     */
    @PreAuthorize("@ss.hasPermi('yqhs:jdjc:add')")
    @Log(title = "监督检查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqhsJdjc yqhsJdjc)
    {
        return toAjax(yqhsJdjcService.insertYqhsJdjc(yqhsJdjc));
    }

    /**
     * 修改监督检查
     */
    @PreAuthorize("@ss.hasPermi('yqhs:jdjc:edit')")
    @Log(title = "监督检查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqhsJdjc yqhsJdjc)
    {
        return toAjax(yqhsJdjcService.updateYqhsJdjc(yqhsJdjc));
    }

    /**
     * 删除监督检查
     */
    @PreAuthorize("@ss.hasPermi('yqhs:jdjc:remove')")
    @Log(title = "监督检查", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yqhsJdjcService.deleteYqhsJdjcByIds(ids));
    }
}
